﻿/*
 * Created by SharpDevelop.
 * User: phtrung
 * Date: 5/25/2009
 * Time: 3:40 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

 using System.Windows.Forms;
 using System.Drawing;
 using System.Data;
 using System.Collections;
 using System;
 using System.Diagnostics;
 using System.Runtime.InteropServices; 
 using System.Drawing.Imaging;
 using System.Configuration;
 using System.IO;
 using popLib;
 using popLib.ExtensionClass;
 using System.Reflection;

namespace SlideShowGadget
{
	/// <summary>
	/// Description of Start.
	/// </summary>
	public class Start: SidebarGadget
	{	
		public enum optionsType { StartupDirectory, DelayTimer, SetAsWallpager, WallpaperStyle }
		public enum WallpaperStyle { Tiled, Centered, Stretched, AutoScaled, FullScaled }
		
		public Start(SidebarContainer sidebarContainer):base(sidebarContainer){
		
			if( !File.Exists(file_config) || !ini_config.isSectionExist("Setting") ){
				ini_config.setValue( "Setting", "Name", "Slideshow Gadget" );
				ini_config.setValue( "Setting", "Description", "View your pictures one by one in specific directory. Double click on image to open it." );
			}
			
			if( !ini_config.isKeyExist( "Setting", "Options" ) ){
				Hashtable options = new Hashtable();
				options.Add( optionsType.StartupDirectory.ToString() , Environment.GetFolderPath( Environment.SpecialFolder.MyPictures ) );
				options.Add( optionsType.DelayTimer.ToString() , "10" );
				options.Add( optionsType.SetAsWallpager.ToString() , "0" );
				options.Add( optionsType.WallpaperStyle.ToString() , "Tiled" );
				ini_config.setValue( "Setting", "Options", StringLib.deParseOption(options) );
			}
						
		}
		
		#region Functions
		public override object InitGadget(){
			if( control == null ){
				control = new SlideShowPanel(this);
				UpdateOptions(false);
			}
			return control;
		}
		
		public override void UpdateOptions(bool reloadSidebar){
	    	if( control == null ) return;
	    	control.StartComponent();
	    }
		
		public override void ViewOptions(){	
			if( sidebarGadgetOption == null ) sidebarGadgetOption = new Options(this);
			sidebarGadgetOption.Show();
		}		
		
		#endregion
		
		
	}
}
